package com.ktgj.customer.service.impl;

import java.util.ArrayList;
import java.util.List;

import cn.hutool.extra.emoji.EmojiUtil;
import com.ktgj.customer.domain.Employee;
import com.ktgj.customer.domain.EmployeeVipresource;
import com.ktgj.customer.mapper.EmployeeVipresourceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ktgj.customer.mapper.EmployeeThingMapper;
import com.ktgj.customer.domain.EmployeeThing;
import com.ktgj.customer.service.IEmployeeThingService;

import javax.annotation.Resource;

/**
 * 待跟进事项Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-09-23
 */
@Service
public class EmployeeThingServiceImpl implements IEmployeeThingService 
{
    @Autowired
    private EmployeeThingMapper employeeThingMapper;
    @Resource
    private EmployeeVipresourceMapper employeeVipresourceMapper;

    /**
     * 查询待跟进事项
     * 
     * @param employeeThingId 待跟进事项ID
     * @return 待跟进事项
     */
    @Override
    public EmployeeThing selectEmployeeThingById(Long employeeThingId)
    {
        return employeeThingMapper.selectEmployeeThingById(employeeThingId);
    }

    /**
     * 查询待跟进事项列表
     * 
     * @param employeeThing 待跟进事项
     * @return 待跟进事项
     */
    @Override
    public List<EmployeeThing> selectEmployeeThingList(Employee employee, EmployeeThing employeeThing)
    {
        EmployeeVipresource employeeVipresource = new EmployeeVipresource();
        employeeVipresource.setEmployeeId(employee.getEmployeeId());
        List<EmployeeVipresource> lstVipResource = employeeVipresourceMapper.selectEmployeeVipresourceList(employeeVipresource);
        List<EmployeeThing> lstEmployeeThing = employeeThingMapper.selectEmployeeThing();
        List<EmployeeThing> lstTmpData = new ArrayList<>();
        for (EmployeeThing thing : lstEmployeeThing)
        {
            EmployeeVipresource vipresource = lstVipResource.stream().filter(item -> item.getCustomerId().equals(thing.getCustomerId())).findFirst().orElse(null);
            if (vipresource != null)
            {
                lstTmpData.add(thing);
            }
        }
        return lstTmpData;
    }

    /**
     * 新增待跟进事项
     * 
     * @param employeeThing 待跟进事项
     * @return 结果
     */
    @Override
    public int insertEmployeeThing(EmployeeThing employeeThing)
    {
        return employeeThingMapper.insertEmployeeThing(employeeThing);
    }

    /**
     * 修改待跟进事项
     * 
     * @param employeeThing 待跟进事项
     * @return 结果
     */
    @Override
    public int updateEmployeeThing(EmployeeThing employeeThing)
    {
        return employeeThingMapper.updateEmployeeThing(employeeThing);
    }

    /**
     * 批量删除待跟进事项
     * 
     * @param employeeThingIds 需要删除的待跟进事项ID
     * @return 结果
     */
    @Override
    public int deleteEmployeeThingByIds(Long[] employeeThingIds)
    {
        return employeeThingMapper.deleteEmployeeThingByIds(employeeThingIds);
    }

    /**
     * 删除待跟进事项信息
     * 
     * @param employeeThingId 待跟进事项ID
     * @return 结果
     */
    @Override
    public int deleteEmployeeThingById(Long employeeThingId)
    {
        return employeeThingMapper.deleteEmployeeThingById(employeeThingId);
    }
}
